<?php
    require_once(MODEL_PATH.'/CMS/Base.php');
    class Model_CMS_Event extends MODEL_CMS_Base{
        
        function __construct(){
        }
         
		
		function get_application_content($application_id){
			$dbh_r = $this->db_connect('read');
			
			$content_json = db_select_one($dbh_r, 'select message_json from event_application where id=? and status > 0', $application_id);
			
			if($content_json == '')
				return '';
			$a_content = json_decode($content_json, true);
			
			$content_view = '';

			
			foreach ($a_content as $key => $value){
				//$content_view .= html_img('/'.$value['p'], '').'<br>';


				if($key == "photo"){
					$content_view .= html_img('/'.$value, '/'.$value, '', '150x150', array('openwin'	=> 1)).'<br>';
				}else if($key == 'questions'){

					$count = 0;
					for ($i=0; $i<count($value); $i++){
					$cname = db_select_one($dbh_r, "select cname from event_question where oid=? order by priority desc, id limit $count, 1", $event_id);
					$answer = $value[$count];
					$count++;
					$content_view .= "$count . $cname <br /><br /> $answer <br /><br />";
					}
				}

			}
			
			return $content_view;
		}
    }
    
    ?>
